package com.lkd.controller;

import com.lkd.result.Result;
import com.lkd.service.ReportService;
import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/order-service/report")
public class ReportController {
    private final ReportService reportService;

    //订单统计
    @GetMapping("/orderCount")
    public Result orderCount(
            @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")LocalDateTime start,
            @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime end
    ){
        Integer count =   reportService.orderCount(start,end);
        return Result.success(count);
    }
    //销售额统计
    @GetMapping("/orderAmount")
    public Result salesAmount(
            @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")LocalDateTime start,
            @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")LocalDateTime end
    ){
        Double sales= reportService.orderAmount(start, end);
        return Result.success(sales);
    }
}
